#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    : 2023/12/2 16:28
# @function: the script is used to do something.
# @version :
import re

import requests
from lxml import etree


# 获取资源地址
url = 'https://www.77xsw.cc/fenlei/1_1/'

response = requests.get(url)
response.encoding = 'gbk'
# html = etree.HTML(response.text)
#
# # xpath 获取的数据是列表信息
# html1 = html.xpath('//div[@id="mm_14"]/ul/li[position() >1]')[0]

html = etree.HTML(response.text)
href_list = html.xpath('//span[@class="sp_2"]/a/@href')
title_list = html.xpath('//span[@class="sp_2"]/a/text()')
for href, title in zip(href_list, title_list):
    item = {}
    item['title'] = title
    item['href'] = href
    print(item)

